package dto

import (
	"danmu/common"
	"danmu/model"
)

type RelationsDto struct {
	Uid uint `json:"Uid"`
	Name string `json:"Name"`
	Sign string `json:"Sign"`
	Face string `json:"Face"`
}

//关注列表
func ToFollowingDto(following []model.Relations,count int) []RelationsDto {
	DB :=common.GetDB()
	newFollowing := make([]RelationsDto,count)
	for i:= 0;i < len(following);i++{
		var userInfo = model.User{}
		newFollowing[i].Uid = following[i].BuddyId
		//查询用户信息
		DB.First(&userInfo, following[i].BuddyId)
		newFollowing[i].Name = userInfo.Name
		newFollowing[i].Sign = userInfo.Sign
		newFollowing[i].Face = userInfo.Face
	}
	return newFollowing
}

//粉丝列表
func ToFollowerDto(follower []model.Relations,count int) []RelationsDto {
	DB :=common.GetDB()
	newFollower := make([]RelationsDto,count)
	for i:= 0;i < len(follower);i++{
		var userInfo = model.User{}
		newFollower[i].Uid = follower[i].Uid
		//查询用户信息
		DB.First(&userInfo, follower[i].Uid)
		newFollower[i].Name = userInfo.Name
		newFollower[i].Sign = userInfo.Sign
		newFollower[i].Face = userInfo.Face
	}
	return newFollower
}